home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Latest Windows '95 Programs
/
The Latest Windows 95 Programs.iso
/
win95
/
utility
/
grep32
/
grep32.doc
next >
Wrap
Text File
|
1993-10-07
|
5KB
|
118 lines
grep32.doc Version 1.0.0 October 7, 1993
After seeing numerous postings to the net querying the existence of "grep"
for the NT platform I decided to "port" a version of it to "32 bit land".
grep32.exe is based on a version of grep which was originally ported to
the pdp 11 (DECUS C). I cleaned up the code and ported it to MSC 5.1.
I added couple of more modifications and have produced the 32 bit version
for the Windows NT command line. Granted, this is a "quick port" and has
no graphical user interface. I would like to give it one as soon as I
get some more time to play with it.
I believe that this version has all the functionality of the UNIX version
plus a couple more things I threw in.
Please send questions comments, suggestions to:
Marc Geist
Dept. 469
AT&T Information Systems
1200 w. 120th Ave.
Westminster, CO 80234-2795
303-538-2653
mag@dwgrc5.dw.att.com
Quick overview of the grep32 command line and regular expression syntax:
Usage: grep [-bcilmnsvq? -dnnn] "pattern" file1 file2 ... [>ofile] [>>ofile]
Options:
b Each line is preceded by the block number of the file
in which it is found. (based on 512 byte blocks).
c Only print the number of lines matched.
i Ignore the case of each character while matching.
l Only list the names of files containing a match
(or a nonmatch if 'v' option is selected).
m Program prompts for search string (helps in search for ' and ")
n Precede each printed line by its relative line
number in the file.
s Suppress all error messages produced by non-readable files.
v All lines but those matching are printed.
q Suppress header information in output.
dnnn Dump nnn lines of text including the string match line.
> Will create new version of output file.
>> Will append to output file if it exists or will
create it if it does not exist.
? Print this message plus more detailed information on
options and pattern matching.
If the 'm' option is specified, no search pattern is expected on command line.
Wildcards in specified file names are supported via the functionality
provided by \MSVCNT\LIB\SETARGV.OBJ (read your MSC documentaion for a
description of this).
Options can be placed anywhere on the command line and they are additive.
The first occurance of an argument not preceded by '-' will be acknowledged
as the pattern string to be searched for unless the 'm' option has been
specified. Any other arguments not preceded by '-' will be taken as
filenames. The minimum number of arguments must contain at least a pattern
string and a filename or the 'm' option and a filename. If no options are
specified the default condition is an exact pattern search in the filename(s)
specified with all matching lines printed to the screen.
How to construct special regular expression search patterns:
Special Characters:
* Wildcard that matches any character or number of characters.
. (period) matches any one character.
^ (caret) at the beginning of a pattern constrains the pattern
to a match the initial segment of a line.
$ (currency sign) at the end of a pattern constrains the
pattern to a match the final segment of a line.
[ Used to "begin-block" a string of characters for special one-
character matches.
] Used to "end-block" a string of characters for special one-
character matches.
\ Backslash followed by any special character will match that
special character (i.e. "\[" will match the character '[').
Special Constructs:
[str] A non-empty string of characters enclosed by square brackets
will match any one character in the string.
[^str] A non-empty string of characters enclosed by square brackets
and preceded by a "caret" will match any character except
the characters in the string.
- (hyphen) may be used to indicate a range of consecutive
ascii characters (i.e [0-9] = [0123456789]. The '-' loses
its special meaning if it occurs after an initial '^' or is
located last in the string.
\{m\}
\{m,\}
\{m,n\} A one character expression followed by \{m\}, \{m,\}, or
\{m,n\} is an expression that matches a range of occurances
of the one character expression. Values of m and n must be
non-negative integers less than 256. \{m\} matches exactly
m occurances, \{m,\} matches at least m occurances, and
\{m,n\} matches any range of occurances between m and n
inclusive.
\(expression\) An expression enclosed between \( and \) is an expression
that matches whatever the unadorned expression matches.
\n The expression \n matches the same string of characters as
was matched by an expression enclosed between \( and \)
earlier in the same expression. n is a digit and the sub-
expression specified is associated with the n-th
occurance of \( counting from the left. For example the
expression: \(test\).*\1 matches a line containing at least
two occurances of the string "test".
A concatenation of expressions is an expression that matches the con-
catenation of the strings matched by each component of the expression.